<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage;

use App\Models\Activity;


class ActivityOrdersCommon extends  Model
{
    use HasFactory;
    use SoftDeletes;

    protected $table = 'activity_orders_common';

    /**
     * 创建订单
     *
     * @param $activity_id
     * @param $applicant_name
     * @param $applicant_phone
     * @return array
     */
    public static function buildOrderCommon($order_id,$activity_info){

        $insertArr = [
            'order_id'=>$order_id,
            'activity_id'=>$activity_info['id'],
            'activity_name'=>$activity_info['name'],
            'activity_price'=>$activity_info['price'],
            'acticity_iname'=>$activity_info['name'],
            'acticity_start_at'=>$activity_info['start_at'],
            'acticity_end_at'=>$activity_info['end_at'],
            'created_at'=>date('Y-m-d H:i:s'),
        ];

        $orderId = self::query()->insertGetId($insertArr);

        return $orderId;
    }

    /**
     * 根据ID获取数据
     *
     * @param $id
     * @param mixed $columns
     * @return array|Builder
     */
    public static function getActivityIdByOrderID($order_id){
        $activity_id = self::query()->where(['order_id'=>$order_id])->value('activity_id');
        return $activity_id;
    }

    public static function formatListData($data){
        
        return $data;
    }



    
}
